<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
        <tr>
            <td>照片:</td><td><img :src="user.pic"></td>
        </tr>
        <tr>
            <td>姓名:</td><td>{{user.name}}</td>
        </tr>
        <tr>
            <td>年龄:</td><td>{{user.age}}</td>
        </tr>
        <tr>
            <td>好友:</td>
            <td>
                <ul>
                    <li v-for="name in user.friends">{{name}}</li>
                </ul>
            </td>
        </tr>
    </table>
    <input type="button" value="加载数据" @click="f()">
</div>
<script src="js/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            user:{name:"",pic:"",age:"",friends: []}
        },
        methods:{
            f(){
                let u = {name:"苍老师",pic:"a.jpg",age:18,
                    friends: ["传奇哥","克晶姐","马大姐"]};
                //把从服务器请求回来的数据赋值给Vue里面的变量, 因为页面标签和对象
                //的属性值进行了绑定, 当对象属性值发生改变时页面会自动改变
                v.user = u;
            }
        }
    })
</script>
</body>
</html>